<?php $this->load->view('layout/header');?>
<div class="supplier-content-page">
    <div class="product-test-h5">
        <ul class="breadcrumb">
            <li><a href="javascript:;">我的账户</a></li>
            <li class="active"><a href="<?php echo site_url('accountinfo/personal')?>">个人信息</a></li>
        </ul>
        <?php echo execute_alert_message();?>
        <div class="add-product">
            <form class="personal-form-validate form-horizontal" action="<?php echo site_url('accountinfo/editPostPersonal') ?>" method="post" enctype="multipart/form-data">
                <div class="fonter">基本资料</div>
                <div class="row">
                    <div class="col-lg-7">
                        <div class="form-group">
                            <label class="col-sm-1 control-label"><em>* </em>用户昵称</label>
                            <div class="col-xs-5">
                                <input type="hidden" name="uid" value="<?php echo $useInfo->uid;?>"/>
                                <input type="text" name="alias_name" value="<?php echo $useInfo->alias_name;?>" class="form-control required"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label"><em>* </em>性　　别</label>
                            <div class="col-xs-5">
                                <label class="radio-inline">
                                    <input type="radio" name="sex_id" value="0" <?php if ($useInfo->sex_id == 0) : ?>checked="checked"<?php endif; ?>> 保密
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="sex_id" value="1" <?php if ($useInfo->sex_id == 1) : ?>checked="checked"<?php endif; ?>> 男
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="sex_id" value="2" <?php if ($useInfo->sex_id == 2) : ?>checked="checked"<?php endif; ?>> 女
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-1 control-label"><em>* </em>出生年月</label>
                            <div class="col-xs-5">
                                <input type="text" name="birthday" value="<?php echo $useInfo->birthday != '0000-00-00' ? $useInfo->birthday : '';?>" id="start-date" class="form-control laydate-icon required" onclick="laydate({elem:'#start-date',istime: true})">
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-4">
                        <div class="is-personal-portrait">
                            <div class="is-personal-round">
                                <img class="is-personal-img lazy" src="/skins/images/photo0.jpg" data-original="<?php echo $this->config->show_image_url($useInfo->personal_photo)?>">
                                <label class="personal_photo">
                                    <div class="is-personal-shadow">编辑头像</div>
                                    <input type="file" name="personal_photo" style="display: none;">
                                    <input type="hidden" name="personal_photo" value="<?php echo $useInfo->personal_photo ?>">
                                </label>
                            </div>
                            <div class="gs-portrait-right">
                                <div class="gs-portrait-account">
                                    <p>用户账号：<?php echo $useInfo->user_name;?></p>
                                    <p>用户类型：<span><?php echo $this->userTypeName;?></span></p>
                                </div>
                            </div>
                        </div>
                        <p class="is-personal-data">注：请填写真实的资料</p>
                    </div>
                </div>
                <div class="fonter">联系资料</div>
                <div class="form-group">
                    <label class="col-sm-1 control-label"><em>* </em>真实姓名</label>
                    <div class="col-xs-3">
                        <input type="text" name="contacter" value="<?php echo $useInfo->contacter;?>" class="form-control required"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label"><em>* </em>手机号码</label>
                    <div class="col-xs-3">
                        <input type="text" name="mobile_phone" value="<?php echo $useInfo->mobile_phone;?>" class="form-control mobile required"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label">备用手机</label>
                    <div class="col-xs-3">
                        <input type="text" name="cellphone" value="<?php echo $useInfo->cellphone;?>" class="form-control mobile"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-1 control-label"><em>* </em>电子邮件</label>
                    <div class="col-xs-3">
                        <input type="text" name="user_email" value="<?php echo $useInfo->user_email;?>" class="form-control email required"/>
                    </div>
                </div>
                <div class="fonter">账号信息</div>
                <div class="form-group">
                    <label class="col-sm-1 control-label">余额</label>
                    <div class="col-xs-3">
                        <span class="text-primary"><?php echo '￥'.$balance->amount_carry;?></span>
                    </div>
                </div>
                <div class="supplierlist-submit">
                    <button type="submit" class="btn btn-default">保存</button>
                </div>
            </form>
        </div>
    </div>
</div>
<?php $this->load->view('layout/footer');?>
<script type="text/javascript">
    $('.personal-form-validate').validate({
        rules: {
            mobile_phone: {
                required: true,
                mobile:true,
                remote: {
                    url:hostUrl()+'/accountinfo/validateMobilePhone',
                    type: 'post',
                    dataType: 'json',
                    data: {
                        mobile_phone:function(json) {
                            return $('input[name=mobile_phone]').val();
                        },
                        uid:function(json) {
                            return $('input[name=uid]').val();
                        }
                    }
                }
            }
        },
        messages: {
            mobile_phone: {
                required: '请输入您的手机号码',
                mobile: '手机号码格式错误',
                remote: '手机号码已注册'
            }
        }
    });
    $('.form-horizontal').on('change', 'input[type=file]', function (e) {
        var $this = $(this);
        upLoadImg(e.currentTarget.files[0], function (obj) {
            console.log(obj);
            $this.siblings('[type=hidden]').val(obj.save_path);
            $this.parents('.is-personal-round').children('img').attr('src', obj.file_url);
        });
    });
</script>
